<!-- Phan khai bao bien cuc bo-->
<?php
// Luu dieu kien loc hien thoi
if(isset($_REQUEST['hdn_filter'])){
	$v_filter = $_REQUEST['hdn_filter'];
}else{	
	$v_filter = "";
}
$v_enable = "";
if (!$v_is_granted_delete)  {
	$v_enable = "disabled";
}
// Luu ten style hien thoi
$v_current_style_name = "odd_row";
// Luu ten style tiep theo
$v_next_style_name = "";
// Luu ten form
$v_form_name = "f_dsp_all_worktype";
$v_goto_url = "list/worktype_spec/index.php";
$v_count=sizeof($arr_all_worktype);
$v_current_item_id = '';
if (isset($_REQUEST['hdn_item_id'])){
	$v_current_item_id = $_REQUEST['hdn_item_id'];
}
$v_spec_code = "";
if (isset($_REQUEST['hdn_spec_code'])){
	$v_spec_code = $_REQUEST['hdn_spec_code'];
}
$v_dis = "none";
if ($v_count_recordtype > 0){
	$v_dis = "block";
}
$v_spec_worktype_id = $arr_single_worktype_spec['0']['0'];
$v_spec_worktype = $arr_single_worktype_spec['0']['1'];
$v_spec_worktype_name = $arr_single_worktype_spec['0']['10'];
$v_current_status_start = $arr_single_worktype_spec['0']['2'];
$v_detail_status_start = $arr_single_worktype_spec['0']['3'];
$v_task_spec_id_list = $arr_single_worktype_spec['0']['4'];
$arr_task_spec_id = explode(",",$v_task_spec_id_list);
$v_count_task_spec = sizeof($arr_task_spec_id);

$v_method_update_start_id = $arr_single_worktype_spec['0']['5'];
$v_method_update_start_name = _getname($arr_update_work,$v_method_update_start_id);
$v_current_status_end = $arr_single_worktype_spec['0']['6'];
$v_detail_status_end = $arr_single_worktype_spec['0']['7'];
$v_return = $arr_single_worktype_spec['0']['8'];

if($v_return == 1)
	$v_checked = "checked";
else 
	$v_checked = "";
$v_recordtype_list = $arr_single_worktype_spec['0']['9'];
$arr_list_recordtype = explode(",",$v_recordtype_list);
$v_count_list_recordtype = sizeof($arr_list_recordtype);

?>
<!--bang chua tieu de cua form-->
<form action="index.php" name="<?php echo $v_form_name;?>" method="post">
		<input name="hdn_item_id" type="hidden" value="">
		<input name="hdn_list_worktype_id" type="hidden" value="0">
		<input name="fuseaction" type="hidden" value="">
		<input type="hidden" name="hdn_tac_vu_spec" value="">
		<input type="hidden" name="hdn_old_worktype_spec" value="<?=$v_spec_worktype_id?>">
		<input type="hidden" name="hdn_recordtype_id_list" value="">
		<input type="hidden" name="hdn_kind_update" value="">
		<input type="hidden" name="hdn_worktype_code" value="<?=$v_spec_worktype?>">
		<input type="hidden" name="hdn_worktype_id" value="">
		<input type="hidden" name="hdn_spec_worktype" value="<?=$v_type_spec_work?>">
		<input type="hidden" name="hdn_chk_can_return" value="">
		<input type="hidden" name="hdn_spec_task_list" value="">
<table width="99%" cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td class="normal_title"><?php echo CONST_WORKTYPE_SPEC_LIST_TITLE; ?>
			<a id="goto" href="" style=".color:white">#</a>
		</td>
	</tr>
</table>
<!-- bang chua cac tieu thuc loc-->
<table cellpadding="0" cellspacing="0" width="99%">
	<tr>
		<td>
		<div id="tb_header" class="form_table1" style="border: solid 1px #999999; width:100%">
			<table cellpadding="0" cellspacing="6" border="0" >			
				<tr class="normal_label">
					<td><?php echo CONST_WORKTYPE_SPECICAL;?> &nbsp;<input name="txt_worktype_spec"  readonly="true" type="text" class="normal_textbox" size="50%" message="<?php echo CONST_MESSAGE_WORKTYPE_SPEC; ?>"  onKeyDown=" change_focus(document.forms(0),this)" value="<?=$v_spec_worktype_name?>"> &nbsp;<img border="0" src="<?php echo $_ISA_IMAGE_URL_PATH;?>find.gif"  title="<?php echo  CONST_SHOW_CHOSICE_HANDLE_AGENCY?>" class="normal_image" onClick="show_all_onclick('list/worktype_spec/index.php','DISPLAY_CHOOSE_WORKTYPE_SPEC',document.forms(0).hdn_worktype_code,document.forms(0).txt_worktype_spec);"></td>
				</tr>
				<tr class="normal_label">
					<td><?php echo CONST_WORKTYPE_STATUS_RECORD_WHEN_DO_WORK_START;?>&nbsp;<input type="text" name="txt_current_status_start" class="normal_textbox" size="15" value="<?=$v_current_status_start?>" optional = "true" /></td>
				</tr>
				<tr class="normal_label">
					<td><?php echo CONST_WORKTYPE_STATUS_DETAIL_WHEN_DO_WORK_START;?>&nbsp;<input type="text" name="txt_detail_status_start" class="normal_textbox" size="15" value="<?=$v_detail_status_start?>" optional = "true"  /></td>
				</tr>
				<tr class="normal_label">
					<td><?php echo CONST_WORKTYPE_TAC_VU_SPECIAL;?> : </td>
				</tr>
				<!-- tac vu kem theo -->
				<tr style="display:<?php echo $v_dis;?> ">
					<td colspan="5">
					<DIV STYLE="overflow: auto; height:120pt; padding-left:5px;margin:0px">
							<table class="list_table2"  width="100%" cellpadding="0" cellspacing="0">
								<col width="2%"><col width="50%"><col width="48%"><?php
								for ($k = 0; $k < sizeof($arr_spec_task) ; $k++) {
									//$v_item_url_onclick = "change_item_checked(this,'tr_recordtype','rad_recordtype')";					
									$v_spec_id = $arr_spec_task[$k][0];
									$v_spec_name = $arr_spec_task[$k][1];
									//echo $arr_all_recordtype[$k]['3'];
									if ($v_current_style_name == "odd_row"){
										$v_current_style_name = "round_row";
									}else{
										$v_current_style_name = "odd_row";
									}
									$v_item_checked_ = "";
									
									for ($t = 0; $t < $v_count_task_spec; $t++)									
										if ($arr_task_spec_id[$t]==$v_spec_id){
											$v_item_checked_ = "checked";
											break;
									}?>
									
									<tr id="tr_task_id" value="<?php echo $v_spec_id;?>" checked="<?php echo $v_item_checked_;?>" class="<?php echo $v_current_style_name;?>">
										<td ><input type="checkbox" name="chk_task_spec" value="<?php echo $v_spec_id;?>" <?php echo $v_item_checked_;?>  onClick="<?php //echo $v_item_url_onclick;?>" optional = "false">
										</td>
										<td colspan="5 "><?php echo $v_spec_name;?></td>						
									</tr><?php					
								}?>	
									
							</table>
					</DIV>
					</td>
				</tr>
					<!-- ket thuc tac vu kem theo -->
				<tr style="display:<?php echo $v_dis;?> ">
					<td class="normal_label" colspan="2" align="left">
						<input type="radio" name="rad_selectall_1" value="0" onClick="checkall(document.forms(0).chk_task_spec);"><?php echo CONST_RECORD_SELECT_ALL_LABEL?>
						<input type="radio" name="rad_selectall_1" value="1" checked onClick="decheckall(document.forms(0).chk_task_spec);"><?php echo CONST_RECORD_DESELECT_ALL_LABEL?>
					</td>
				</tr>
				<tr class="normal_label">
					<td><?php echo CONST_WORKTYPE_KIND_UPDATE;?>&nbsp;<select class="normal_selectbox" name="sel_result_kind_update" style="width:40%"  message = "<?php echo CONST_KIND_UPDATE_MESSAGE;?>" onChange="sel_onclick(this,document.forms(0).hdn_kind_update);">
            <option id="" value="<?=$v_method_update_start_name?>">--<?php echo CONST_FUNCTION_MENU_LEFT_FOLLOW;?>--</option>
            <?php echo _generate_select_option($arr_update_work,'0','0','1', $v_method_update_start_id);?>
          </select></td>
				</tr>
				<tr class="normal_label">
					<td><?php echo CONST_WORKTYPE_STATUS_RECORD_WHEN_DO_WORK_END;?>&nbsp;<input type="text" name="txt_current_status_end" class="normal_textbox" size="15" value="<?=$v_current_status_end?>"  optional = "true" /></td>
				</tr>
				<tr class="normal_label">
					<td><?php echo CONST_WORKTYPE_STATUS_DETAIL_WHEN_DO_WORK_END;?>&nbsp;<input type="text" name="txt_detail_status_end" class="normal_textbox" size="15" value="<?=$v_detail_status_end?>" optional = "true" /></td>
				</tr>
				<tr class="normal_label" >
					<td checked = "<?=$v_checked?>"><?php echo CONST_WORKTYPE_CAN_RETURN;?>&nbsp; <input type="checkbox" name="ck_can_return" <?=$v_checked?> /></td>
				</tr>
				
				<tr style="display:<?php echo $v_dis;?> ">
					<td class="normal_label" colspan="3"><?php echo CONST_RECORDTYPE_LABEL;?></td>
				</tr>
					<!-- loai ho so -->
					<!-- modified by tuyenntt -->
				<tr style="display:<?php echo $v_dis;?> ">
					<td colspan="5">
					<DIV STYLE="overflow: auto; height:120pt; padding-left:5px;margin:0px">
							<table class="list_table2"  width="100%" cellpadding="0" cellspacing="0">
								<col width="2%"><col width="50%"><col width="48%"><?php
								for ($k=0;$k<$v_count_recordtype;$k++) {
									$v_item_url_onclick = "change_item_checked(this,'tr_recordtype','rad_recordtype')";					
									$v_recordtype_id = $arr_all_recordtype[$k]['PK_RECORDTYPE'];
									$v_recordtype_name = $arr_all_recordtype[$k]['C_NAME'];
									//echo $arr_all_recordtype[$k]['3'];
									if ($v_current_style_name == "odd_row"){
										$v_current_style_name = "round_row";
									}else{
										$v_current_style_name = "odd_row";
									}
									$v_item_checked = "";
									
									for ($j=0; $j<$v_count_list_recordtype; $j++)									
										if ($arr_list_recordtype[$j]==$v_recordtype_id){
											$v_item_checked = "checked";
											break;
									}?>
									
									<tr id="tr_recordtype" value="<?php echo $v_recordtype_id;?>" checked="<?php echo $v_item_checked;?>" class="<?php echo $v_current_style_name;?>">
										<td ><input type="checkbox" name="chk_recordtype" value="<?php echo $v_recordtype_id;?>" <?php echo $v_item_checked;?>  onClick="<?php echo $v_item_url_onclick;?>">
										</td>
										<td colspan="5 "><?php echo $v_recordtype_name;?></td>						
									</tr><?php					
								}?>	
									
							</table>
					</DIV>
					</td>
				</tr>
					<!-- ket thuc loai ho so -->
				<tr style="display:<?php echo $v_dis;?> ">
					<td class="normal_label" colspan="2" align="left">
						<input type="radio" name="rad_selectall" value="0" onClick="checkall(document.forms(0).chk_recordtype);"><?php echo CONST_RECORD_SELECT_ALL_LABEL?>
						<input type="radio" name="rad_selectall" value="1" checked onClick="decheckall(document.forms(0).chk_recordtype);"><?php echo CONST_RECORD_DESELECT_ALL_LABEL?>
					</td>
				</tr>
				<tr>
					<td colspan="2" > <hr color="#66CCFF" size="1"></td>
				</tr>
				<tr class="normal_label">
				<td><input type="button" class="small_button" name="btn_update_spec" value="<?php echo _CONST_SAVE_BUTTON; ?>" onClick="save_task_value_onclick(document.forms(0).chk_task_spec,document.forms(0).hdn_spec_task_list);save_spec_value_onclick('UPDATE_WORKTYPE_SPEC',document.forms(0).ck_can_return,document.forms(0).chk_recordtype,document.forms(0).hdn_recordtype_id_list);">
				</td>
			</tr>

			</table>
		</div>
		</td>
	</tr>
	<!--<tr>
		
		<td align="left" class="large_link">
			<td><a href="#" name="btn_delete" onclick="btn_delete_onclick(document.forms[0].chk_item_id,document.forms[0].hdn_record_id_list,'DELETE_WORKTYPE_SPEC');"><?php echo _CONST_DELETE_BUTTON; ?></a></td>
		</td>
	</tr>-->
	<tr><td height="5"></td></tr>
</table>
<!-- Bat cac phim: F12=false; Insert=true; Delete=true, ESC=false; Enter=false -->
<div id="hotkey" onKeyDown="javascript:process_hot_key(false,true,true,false,false);">
<!--Bang noi dung chua danh sach cac linh vuc-->
<table class="list_table2" width="100%" cellpadding="0" cellspacing="0" border="0">
	<col width="5%"><col width="20%"><col width="30%"><col width="20%"><col width="15%">
	<tr class="header">
		<td align="center">#</td>
		<td align="center"><?php echo CONST_WORKTYPE_CODE_LABEL; ?></td>
		<td align="center"><?php echo CONST_WORKTYPE_NAME_LABEL; ?></td>		
		<td align="left"><?php echo CONST_TAC_VU_SPEC_LABEL; ?></td>
		<td align="center"><?php echo CONST_KIND_UPDATE_LABEL; ?></td>
	</tr>
</table>	
<div style="overflow: auto; width: 100%; height:<?php echo _CONST_HEIGHT_OF_LIST ?>;padding-left:0px;margin:0px">
<table class="list_table2" width="100%" cellpadding="0" cellspacing="0">
	<col width="5%"><col width="20%"><col width="30%"><col width="20%"><col width="15%"><?php
	if ($v_count_spec>0){
		for($row_index = 0;$row_index< $v_count_spec ;$row_index++){
			$v_worktype_id = $arr_all_worktype_spec[$row_index][0];
			$v_worktype_code = $arr_all_worktype_spec[$row_index][1];
			$v_worktype_name = $arr_all_worktype_spec[$row_index][9];
			$v_spec_task_start = $arr_all_worktype_spec[$row_index][4];
			$arr_list_spec_task = explode(",",$v_spec_task_start);			
			$v_spec_task_start_name = "";
			for($i = 0 ; $i < sizeof($arr_list_spec_task) ; $i++)
			{			
				$v_spec_task_start_name .= _getname($arr_spec_task,$arr_list_spec_task[$i]).", ";
			}
			$v_update_method_start = $arr_all_worktype_spec[$row_index][5];	
			$v_update_method_start_name = _getname($arr_update_work,$v_update_method_start);				
			$v_url = "row_onclick(document.forms(0).hdn_worktype_id"  . ",'" . $v_worktype_id . "'," . "'DISPLAY_ALL_WORKTYPE_SPEC','" . $v_goto_url . "')";
			
			if($v_spec_worktype_id == $v_worktype_id)
				$v_current_style_name = "red_row";			
			else if ($v_current_style_name == "odd_row"){
				$v_current_style_name = "round_row";
			}else{
				$v_current_style_name = "odd_row";
			}
			
			?>	
			<tr class="<?php echo $v_current_style_name ?>" id="<?=$v_worktype_id?>"> 
				<td align="center">
					<input type="checkbox" name="chk_worktype_id" value="<?php echo $v_worktype_id; ?>">
				</td>
				<td align="left"  onclick="<?php echo $v_url ;?>" class="normal_label">
					<a name="<?php echo $v_worktype_id;?>"><?php echo $v_worktype_code; ?>&nbsp;</a>
				</td>
				<td align="left"  onclick="<?php echo $v_url ;?>" class="normal_label">
					<a name="<?php echo $v_worktype_id;?>"><?php echo $v_worktype_name; ?>&nbsp;</a>
				</td>
				<td align="center" onclick="<?php echo $v_url ;?>">
					<a name="<?php echo $v_worktype_id;?>"><?php echo $v_spec_task_start_name; ?>&nbsp;</a>
				</td>
				<td align="center"  onclick="<?php echo $v_url ;?>" class="normal_label">
					<a name="<?php echo $v_worktype_id;?>"><?php echo $v_update_method_start_name; ?>&nbsp;</a>
				</td>
			</tr><?php 
		}	
	}
	
	
	if ($v_current_style_name == "odd_row"){
		$v_next_style_name = "round_row";
	}else{
		$v_next_style_name = "odd_row";
	}
	if ($v_current_style_name == "red_row")
	{
		$v_current_style_name ="odd_row" ;
		$v_next_style_name = "round_row";
	}
	else{
		$v_next_style_name = "odd_row";
	}
	echo _add_empty_row($v_count,_CONST_NUMBER_OF_ROW_PER_LIST,$v_current_style_name,$v_next_style_name,5);
	?>
</table>
</div>
<!--Table chua cac button-->
<table align="center">	
	<tr>
		<td align="left">		
		<?php
			if ($v_is_granted_update){?>
				<input type="button" value="<?php echo _CONST_ADD_BUTTON; ?>" name="btn_add" class="normal_button" onClick="btn_add_onclick(document.forms(0).hdn_worktype_id, 'DISPLAY_ALL_WORKTYPE_SPEC')"><?php
			}	
			if ($v_is_granted_delete){?>
				<input type="button" value="<?php echo _CONST_DELETE_BUTTON; ?>" name="btn_delete" class="normal_button" onClick="btn_delete_onclick(document.forms(0).chk_worktype_id,document.forms(0).hdn_list_worktype_id,'DELETE_WORKTYPE_SPEC')"><?php
			}?>
		</td>
	</tr>
</table>
</div id="hotkey">
</form>
<Script>
	document.all.goto.href="#<? echo $v_current_item_id;?>";
	document.all.goto.click();
</Script>

